#!/usr/bin/groovy
@Library('test-shared-library') _

// Job parameters
properties(
        [
                parameters(
                        [
                                booleanParam(name: 'runUnitTests', defaultValue: true, description: 'Run Scala unit tests'),
                                booleanParam(name: 'runPyUnitTests', defaultValue: true, description: 'Run Python unit tests'),
                                booleanParam(name: 'runRUnitTests', defaultValue: true, description: 'Run R unit tests'),
                                booleanParam(name: 'runIntegTests', defaultValue: false, description: 'Run Scala integration tests'),
                                booleanParam(name: 'runPyIntegTests', defaultValue: false, description: 'Run Python integration tests'),
                                choice(
                                        choices: 'both\ninternal\nexternal',
                                        description: "Choose in which mode to run tests",
                                        name: 'backendMode'
                                )
                        ]
                ),
                buildDiscarder(logRotator(numToKeepStr: '10'))
        ]
)

cancelPreviousBuilds()

def pipeline
def sparkVersions
def testH2OBranch
node("docker") {
    cleanWs()
    checkout scm
    pipeline = load 'ci/sparklingWaterPipeline.groovy'
    def commons = load 'ci/commons.groovy'
    sparkVersions = commons.getSupportedSparkVersions()
    testH2OBranch = commons.loadGradleProperties("gradle.properties")["testH2OBranch"]
}


pipeline(params) { p ->
    sparkMajorVersions = sparkVersions
    runUnitTests = "${p.runUnitTests}"
    runPyUnitTests = "${p.runPyUnitTests}"
    runRUnitTests = "${p.runRUnitTests}"
    runIntegTests = "${p.runIntegTests}"
    runPyIntegTests = "${p.runPyIntegTests}"
    buildAgainstH2OBranch = "true"
    h2oBranch = testH2OBranch
    hadoopVersion = "2.7"
    driverHadoopVersion = "hdp2.2"
    uploadNightly = "false"
    uploadNightlyDockerImages = "false"
    backendMode = "${p.backendMode}"
}
